/**
 *
 *   █████▒█    ██  ▄████▄   ██ ▄█▀       ██████╗ ██╗   ██╗ ██████╗
 * ▓██   ▒ ██  ▓██▒▒██▀ ▀█   ██▄█▒        ██╔══██╗██║   ██║██╔════╝
 * ▒████ ░▓██  ▒██░▒▓█    ▄ ▓███▄░        ██████╔╝██║   ██║██║  ███╗
 * ░▓█▒  ░▓▓█  ░██░▒▓▓▄ ▄██▒▓██ █▄        ██╔══██╗██║   ██║██║   ██║
 * ░▒█░   ▒▒█████▓ ▒ ▓███▀ ░▒██▒ █▄       ██████╔╝╚██████╔╝╚██████╔╝
 *  ▒ ░   ░▒▓▒ ▒ ▒ ░ ░▒ ▒  ░▒ ▒▒ ▓▒       ╚═════╝  ╚═════╝  ╚═════╝
 *  ░     ░░▒░ ░ ░   ░  ▒   ░ ░▒ ▒░
 *  ░ ░    ░░░ ░ ░ ░        ░ ░░ ░
 *           ░     ░ ░      ░  ░
 */

using UnityEngine;
public class Skill 
{
	public int skillBaseID;
	public int skillDisplayID;

	public Skill_Base skillBase;
	public SKill_Display display;

	public Actor[] targets;

	private bool bulletSkill;		//投射技能or即时技能
	public Bullet bullet;


	private Timer skillTimer;
	public bool canBreak = true;

    public delegate void SkillEventHandler();
    public event SkillEventHandler Event_Use;
    public event SkillEventHandler Event_Start;
    public event SkillEventHandler Event_Break;
    public event SkillEventHandler Event_Projection;
    public event SkillEventHandler Event_Hurt;
    public event SkillEventHandler Event_End;

	public Skill(int id)
	{

	}
	public Skill(int skillBaseID,int skillDisplayID)
	{
		bulletSkill = false;
	}

	public bool UseSkill()
	{
		if (skillBase.UseCheck()) 
		{
			Event_Use();
			skillBase.CoolDown();
			UseSkillWithoutCheck();
			return true;
		}
		return false;
	}

	public void UseSkillWithoutCheck()
	{
		Event_Start();
		display.PlayStart();
		skillBase.Event_BeCantBreak += delegate()
		{
			canBreak = false;
		};
		skillBase.BreakTimer();
		skillTimer = new Timer(skillBase.hitTime);
		skillTimer.tick += delegate()
		{
			if (bulletSkill) 
			{
				bullet.Event_Hurt += Hurt;
				bullet.Start();
			}
			else
			{
				new Box(1,1,1,Vector3.zero,0).collect(ref targets, Vector3.zero, 0);
				Hurt(new Vector3(0,0,0));
			}
		};
		skillTimer.Start();
	}
	public bool Break()
	{
		if (canBreak) 
		{
			skillBase.Break();
			return true;
		}
		return false;
	}


	public int Hurt(Vector3 pos, ref Collider[] c)
	{
		return 0;
	}
	public int Hurt(Vector3 pos)
	{
		return Hurt(pos);
	}
	public int Hurt()
	{
		return Hurt(new Vector3(0,0,0));
	}
}